package com.tjsinfo.tjsoa.workReport.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tjsinfo.tjsoa.common.ToolKit;
import com.tjsinfo.tjsoa.workReport.bo.TResourceWorkReportManage;
import com.tjsinfo.tjsoa.workReport.vo.TResourceWorkReport;


public class WorkReportViewAction extends Action {
	
	private TResourceWorkReportManage resourceWorkReportManage;
	
	

	public TResourceWorkReportManage getResourceWorkReportManage() {
		return resourceWorkReportManage;
	}



	public void setResourceWorkReportManage(
			TResourceWorkReportManage resourceWorkReportManage) {
		this.resourceWorkReportManage = resourceWorkReportManage;
	}
	
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		try {
			String path = request.getSession().getServletContext().getRealPath(
					"/");
			String id=request.getParameter("id");
			TResourceWorkReport workReport = resourceWorkReportManage.findById(Integer.parseInt(id));
			ToolKit.copyFile("d:\\gongwen\\"+workReport.getContent(), path+"\\"+workReport.getContent());
			request.setAttribute("workReport", workReport);
			return mapping.findForward("success");
		} catch (Exception e) {
			e.printStackTrace();
			return mapping.findForward("failed");
		}
	}
}
